/***************************************************************************
 * 文件名:CodingSchemesDAO.java<br>
 * 版本: <br>
 * 描述: <br>
 * 版权所有: <br>
 * //////////////////////////////////////////////////////// <br>
 * 创建者: robo<br>
 * 创建日期: 2010-11-15 <br>
 * 修改者: <br>
 * 修改日期: <br>
 * 修改说明: <br>
 **************************************************************************/
package com.sunwayhorizo.health.ets.base.service.dao;

import java.util.List;

import javax.ejb.Stateless;
import javax.persistence.Query;

import org.jboss.seam.annotations.JndiName;
import org.jboss.seam.annotations.Name;

import com.sunwayhorizo.health.ets.base.common.BaseDao;
import com.sunwayhorizo.health.ets.base.persistent.EtCodingSchemes;

@Stateless
@Name("CodingSchemesDao")
public class CodingSchemesDao extends BaseDao implements ICodingSchemesDao {

	public EtCodingSchemes getCodingSchemeForName(String name){
		String jpql = "select o from EtCodingSchemes o where o.codingschemeEnName =: codingschemeEnName";
		Query query = entityManager2.createQuery(jpql);
		query.setParameter("codingschemeEnName", name);
		List<EtCodingSchemes> list = query.getResultList();
		if(list != null && list.size()>0){
			return (EtCodingSchemes)list.get(0);
		}
		return null;
	}
	
	public List<EtCodingSchemes> getAllCodingSchemes(){
		String jpql = "select o from EtCodingSchemes o  ";
		return entityManager2.createQuery(jpql).getResultList();
	}
	
	public EtCodingSchemes getCodingSchemeByOID(String oid){
		if(oid == null  || oid.equals("")){
			return null;
		}
	
		String jpql = " select o from EtCodingSchemes o where o.codingschemeOid =:codingschemeOid ";
		Query query = entityManager2.createQuery(jpql);
		query.setParameter("codingschemeOid", oid);
		List<EtCodingSchemes> list = query.getResultList();
		if(list != null && list.size() >  0 ){
			return (EtCodingSchemes)list.get(0);
		}
		return null;
	}
}


